﻿@{
    //page title
    ViewBag.Title = T("Admin.Customers.CustomerActions").Text;
}

<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption">
                    <i class="fa fa-users"></i>
                    @T("Admin.Customers.CustomerActions")
                </div>
                <div class="actions">
                    <a href="@Url.Action("Create")" class="btn green"><i class="fa fa-plus"></i><span class="hidden-xs"> @T("Admin.Common.AddNew") </span></a>
                </div>
            </div>
            <div class="x_content form">
                <div id="customeractions-grid"></div>
            </div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function () {
        $("#customeractions-grid").kendoGrid({
            dataSource: {
                transport: {
                    read: {
                        url: "@Html.Raw(Url.Action("List", "CustomerAction"))",
                        type: "POST",
                        dataType: "json",
                        data: addAntiForgeryToken
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total",
                    errors: "Errors"
                },
                error: function(e) {
                    display_kendoui_grid_error(e);
                    // Cancel the changes
                    this.cancelChanges();
                },
                serverPaging: true,
                serverFiltering: true,
                serverSorting: true
            },
            pageable: {
                refresh: true,
                numeric: false,
                previousNext: false,
                info: false
            },
            editable: {
                confirmation: false,
                mode: "inline"
            },
            scrollable: false,
            columns: [{
                field: "Name",
                title: "@T("Admin.Customers.CustomerAction.Fields.Name")",
                width: 300,
                template: '<a class="k-link" href="Edit/#=Id#">#=kendo.htmlEncode(Name)#</a>',
            }, {
                field: "ActionType",
                title: "@T("admin.customers.actiontype.fields.name")",
                width: 100
            },
            {
                field: "Active",
                title: "@T("Admin.Customers.CustomerAction.Fields.Active")",
                width: 50,
                headerAttributes: { style: "text-align:center" },
                attributes: { style: "text-align:center" },
                template: '# if(Active) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
            }]
        });
    });
</script>
